-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wgsl missing float image format inference #5716
Conversation
Looks good to me. Thank you for your contribution! |
There is a test whose expected result needs to be updated. |
Not sure how to do that. |
Actually the test failed because the generated spirv failed validation. We need to investigate which validation rule is being violated. |
On my computer that test doesn't fail so I'm not sure how to proceed. |
You probably didn't enable the SPIRV validation.
|
The test fails due to this line I've been unable to figure out where to put the inference code though I'm still looking. |
Ah, actually we do want to have The reasoning is that when the user defines something like |
I could infer for |
It would require modifying the test to use float4 instead of float, but since the test doesn't work with half, it is already testing a special case. |
Inferring for It is safer to not infer for The right fix to this problem IMO, is to allow user to write |
People can use attributes to specify format as well. |
For WGSL where there isn't a "unknown" format, I agree that any inference is better. |
Perhaps we should do this during wgsl emit time, so we can do a last minute infer for wgsl when the default front-end infer failed. |
Looks like that's what glsl does. Converted over to using that. |
Looks good, need a formatting pass. |
/format |
🌈 Formatted, please merge the changes from this PR |
Format code for PR shader-slang#5716
@@ -343,6 +345,38 @@ static const char* getWgslImageFormat(IRTextureTypeBase* type) | |||
// | |||
ImageFormat imageFormat = | |||
type->hasFormat() ? (ImageFormat)type->getFormat() : ImageFormat::unknown; | |||
|
|||
if (imageFormat == ImageFormat::unknown) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the switch
statement right after this if
, there is a case for ImageFormat::unknown
.
This code change could be placed inside of the switch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally had it inside the switch statement. Having it outside makes it a bit easier to mentally parse imo. It's the difference between
handle edge cases
do main operation
and
do main operation except in the case of edge cases where you handle them
fixes #5704